<html>
  <head>
    <script type="text/javascript" src="chrome_ex_oauthsimple.js"></script>
    <script type="text/javascript" src="chrome_ex_oauth.js"></script>
    <script type="text/javascript">
      var ANALYTICS_SCOPE = 'https://www.google.com/analytics/feeds/';
      //var DOCLIST_FEED = DOCLIST_SCOPE + '/default/private/full/';
      var docs = []; // In memory cache for the user's list of profiles.
      var refreshRate = localStorage.refreshRate || 300; // 5 min default.
      var pollIntervalMin = 1000 * refreshRate;
      var requests = [];

      var oauth = ChromeExOAuth.initBackgroundPage({
        'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken',
        'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken',
        'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken',
        'consumer_key': 'anonymous',
        'consumer_secret': 'anonymous',
        'scope': ANALYTICS_SCOPE,
        'app_name': 'Google Analytics: Chrome Extension'
      });
	  
	  /*var oauth = ChromeExOAuth.initBackgroundPage({
	  'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken',
	  'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken',
	  'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken',
	  'consumer_key': 'anonymous',
	  'consumer_secret': 'anonymous',
	  'scope': 'https://docs.google.com/feeds/',
	  'app_name': 'My Google Docs Extension'
	});*/

	  oauth.authorize(function() {
		  // ... Ready to fetch private data ...
		  alert('authorized');
	  });

      function logout() {
        docs = [];
        setIcon({'text': ''});
        oauth.clearTokens();
        clearPendingRequests();
      };
	  
	  var currentTab;
	  function changeHostPage(){
		
		 chrome.tabs.sendRequest(currentTab.id, {greeting: "hello"}, function(response) {
			console.log(response);
		  });
	  }
	  
	  chrome.tabs.getSelected(null, function(tab) {
	  currentTab = tab;
	  console.log(currentTab);
	  chrome.tabs.sendRequest(currentTab.id, {greeting: "hello"}, function(response) {
		console.log(response);
	  });
	});
	  
	  
    </script>
  </head>
  <body>
  </body>
</html>
